import { Message, Notification } from 'element-ui'
let messageInstance = null;
let messageInstance2=null
function topTips(text, types) {
    // let elemnts=document.getElementsByClassName('el-message')
    // if (elemnts.length === 0) {
        if(messageInstance&&text){
            messageInstance.close()
        }
        if (types != "errno") {
            messageInstance=Message({
                message: text,
                type: types,
                // types的值 
                //成功信息 success
                //错误信息 error
                //警告信息 warning
                //消息提示 info
                // this.topTips("删除成功!","success")书写方式
                duration: 2000
            });
        } else {
            messageInstance=Message({
                message: text,
                type: "error",
                duration: 2000
            });
        }
    // }
}
function rightTips(text, types) {
        if(messageInstance2&&text){
            messageInstance2.close()
        }
        if (types != "errno") {
            messageInstance2=Notification({
                message: text,
                type: types,
                // types的值 
                //成功信息 success
                //错误信息 error
                //警告信息 warning
                //消息提示 info
                // this.rightTips("删除成功!","success")
                duration: 2000
            });
        } else {
            messageInstance2=Notification({
                message: text,
                type: "error",
                duration: 2000
            });
        // }
    }
}

export { topTips, rightTips }